var http = require('http');
var ttr = "127.0.0.1"
var but = 8888;
var name='这是主页'；

http.createServer(function (request, response) {
    console.log(request.url)
    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
   /* response.writeHead(200, {'Content-Type': 'text/html'});*/
    response.statusCode = 200 ;
    response.statusMessage = "" ;
    response. setHeader('Content-Type', 'text/html');
    response.setHeader("Server","private server");

    var s ="";
    if (request.url == "/index.html"){
        s = "<html><head></head><body><h1>这是主页</h1><a href='index.html'>主页</a><a href='about.html'>关于</a></body></html>"
    }else if(request.url == "/about.html"){
         s = "<html><head></head><body><h1>这是关于</h1><a href='index.html'>主页</a><a href='about.html'>关于</a></body></html>"
    }


    // 发送响应数据 "Hello World"
    response.end(s);
}).listen(port);

// 终端打印如下信息
console.log('Server running at http://%s:%s/',ip,port);